package com.crm.service.impl.userForumManager;

import com.crm.dao.mapper.customMapper.userForumCustomManager.UserForumCustomMapper;
import com.crm.dao.mapper.userForumManager.UserForumMapper;
import com.crm.model.entity.userForumManager.UserForum;
import com.crm.model.qo.userForumManager.UserForumQO;
import com.crm.model.vo.userForumManager.UserForumInfoVO;
import com.crm.model.vo.userForumManager.UserForumVO;
import com.crm.service.userForumManager.UserForumDbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author:chaifuyou
 * @Date: 2021/5/24 9:44
 */
@Service
public class UserForumDbServiceImpl implements UserForumDbService {

    @Autowired
    private UserForumMapper userForumMapper;

    @Autowired
    private UserForumCustomMapper userForumCustomMapper;

    /**
     * 查询论坛信息
     * @param userForumQO
     * @param order
     * @return
     */
    @Override
    public List<UserForumVO> selectUserForumListPage(UserForumQO userForumQO, String order) {
        return userForumCustomMapper.selectUserForumListPage(userForumQO,order);
    }

    /**
     * 发布论坛
     * @param userForum
     */
    @Override
    public void addUserForum(UserForum userForum) {
        userForumMapper.insertSelective(userForum);
    }

    /**
     * 获取用户的论坛信息
     * @param accountId
     * @return
     */
    @Override
    public UserForumInfoVO selectLoginUserForumInfo(String accountId) {
        return userForumCustomMapper.selectLoginUserForumInfo(accountId);
    }

    /**
     * 删除论坛
     * @param userForumId
     * @return
     */
    @Override
    public boolean delUserForum(String userForumId) {
        return userForumCustomMapper.delUserForum(userForumId) > 0;
    }
}
